package view;

import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionListener;

import javax.swing.JFrame;
import javax.swing.JLabel;

import controller.PrincipalControler;

import view.utils.MenuView;
import view.windowBehavior.McWinLookAndFeelBehavior;
import view.windowBehavior.WindowBehavior;

public class PainelPrincipal extends JFrame implements View {

	private static final long serialVersionUID = 1L;

	private MenuView menuBar;

	private JLabel labelImagem;

	private ActionListener controle;

	private WindowBehavior windowBehavior;

	public PainelPrincipal(ActionListener controle) {
		this.controle = controle;
		init();
		layoutComponents();
		setup();
	}

	private void setup() {
		setTitle("");
		setJMenuBar(menuBar);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		Dimension screenTela = Toolkit.getDefaultToolkit().getScreenSize();
		this.setBounds(0, 0, screenTela.width, screenTela.height - 35);
		this.setResizable(true);
	}

	private void layoutComponents() {
		getContentPane().add(labelImagem);
	}

	private void init() {

		menuBar = new MenuView(new PrincipalControler());

		labelImagem = new JLabel();
		// labelImagem = new JLabel(new ImageIcon(getClass().getResource(
		// "images/h.jpg")), SwingConstants.CENTER);
		labelImagem.setVisible(true);
		
		windowBehavior = new McWinLookAndFeelBehavior();

	}

	public void close() {
		dispose();
	}

	public void exibir() {
		setVisible(true);
	}

	@Override
	public void fechar() {
		dispose();
	}

	public WindowBehavior getWindowBehavior() {
		return windowBehavior;
	}

	public void setWindowBehavior(WindowBehavior windowBehavior) {
		this.windowBehavior = windowBehavior;
	}
	
	public static void main(String[] args) {
		new PainelPrincipal(null).exibir();
	}

}
